﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using automobili_data;

namespace automobili_gui.UserManagement
{
    public partial class Login : System.Web.UI.Page
    {
        User currentUser = null;
        
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void loginForm_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                currentUser = automobili_data.AutomobiliDataManager.instance.getUser(loginForm.UserName, loginForm.Password);
                SessionUtils.storeUserInformation(currentUser);
                loginForm.DestinationPageUrl = WebSiteController.onSuccessfullyLoginUrl();
                e.Authenticated = true;
            }
            catch (automobili_data.interfaces.exceptions.UserException ex)
            {
                e.Authenticated = false;
            }
        }

    }
}